﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;

//////////////////////////////////////////////////////////////////////////
//Log.aspx.cs                                                           //
//Last Edited: 23 Mar 2012                                              //
//                                                                      //
//Displays the log of changes to the schedule.                          //
//////////////////////////////////////////////////////////////////////////
public partial class Advisee_Log : System.Web.UI.Page
{
    //////////////////
    //Page Functions//
    //////////////////

    /// <summary>
    /// Page_Load()
    /// 
    /// Initializes the page.
    /// </summary>
    /// <param name="sender">object sender (unused, required by ASP.NET) - web control that called the function</param>
    /// <param name="e">EventArgs e (unused, required by ASP.NET) - other arguments for the function</param>
    protected void Page_Load(object sender, EventArgs e)
    {
        //Initialize main box to empty
        LogBox.Text = "";
        //List out log entries from database
        List<Dictionary<String, Object>> results = StoredProcedures.getLogEntries(SharedFunctions.getAdviseeID(Request));
        foreach (Dictionary<String, Object> i in results)
        {
            //Take off the timestamp (just want the date)
            String date = i["date"].ToString();
            date = date.Substring(0, date.Length - 12);
            LogBox.Text += date + " - " + i["author"] + " Updated" + System.Environment.NewLine; 
        }
    } //end Page_Load()

    /// <summary>
    /// CloseButton_Click()
    /// 
    /// Called when user clicks the close button.
    /// </summary>
    /// <param name="sender">object sender (unused, required by ASP.NET) - web control that called the function</param>
    /// <param name="e">EventArgs e (unused, required by ASP.NET) - other arguments for the function</param>
    protected void CloseButton_Click(object sender, EventArgs e)
    {
        //Redirect to default
        Response.Redirect("~/Advisee/Default.aspx");
    } //end CloseButton_Click()

    /// <summary>
    /// HelpButton_Click()
    /// 
    /// Called when user clicks the help button.
    /// </summary>
    /// <param name="sender">object sender (unused, required by ASP.NET) - web control that called the function</param>
    /// <param name="e">EventArgs e (unused, required by ASP.NET) - other arguments for the function</param>
    protected void HelpButton_Click(object sender, EventArgs e)
    {
        //Redirect to help
        Response.Redirect("~/Advisee/Help.aspx");
    } //end HelpButton_Click()
}